package com.example.cmtwo.mapper;

import com.example.cmtwo.bean.Commodity;
import com.example.cmtwo.bean.User;
import com.example.cmtwo.bean.Userinformation;
import org.apache.ibatis.annotations.*;

import java.util.List;



@Mapper
public interface UserMapper {

    @Select("select * from user where Uname = #{Uname}")
    public List<User> getUserByName(String Uname)throws Exception;

    @Select("select * from commodity")//查询所有商品信息
    public List<Commodity> findallcominformation() throws Exception;
    @Select("select * from userinformation")//查询所有用户信息
    public  List<Userinformation> findalluserinformation() throws Exception;
    @Select("select * from user")//查询所有账号信息
    public  List<User> findalluser() throws Exception;


    @Delete("delete from user where Uid = #{Uid}")
    public int deleteUserById(Integer id)throws Exception;

    //@Options注解，告诉程序Uid字段为自增模式，无需导入S
    @Options(useCache = true,keyColumn = "Uid")
    @Insert("insert into User(Uname, Upassword) value(#{Uname},#{Upassword})")
    public int insertUser(@Param("Uname") String Uname, @Param("Upassword") String Upassword)throws Exception;

    @Update("update User set Uname=#{Uname},Upassword=#{Upassword}")
    public int updateUser(User user)throws Exception;

    //***********By GeJian*************
    //更改用户账号
    @Update("update user set Uname=#{Uname} where Uid=#{Uid}")
    public int updateUname(@Param("Uid") Integer Id, @Param("Uname") String Name)throws Exception;

    //***********By GeJian*************
    //更改用户呢称
    @Update("update userinformation set name=#{Name} where Uid=#{Uid}")
    public int updateOwnMesName(@Param("Uid") Integer Id, @Param("Name") String Name)throws Exception;

    //***********By GeJian*************
    //更改用户信息
    @Update("update userinformation set Son=#{Son},Idphoto=#{Idphoto},Sex=#{Sex},QQ=#{QQ},Intro=#{Intro} where Uid=#{Uid}")
    public int updateOwnMes(@Param("Uid") Integer Id, @Param("Son") String Son, @Param("Idphoto") String phone, @Param("Sex") String Sex, @Param("QQ") String QQ, @Param("Intro") String Intro)throws Exception;

}
